package com.billdowney.service.impl.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import com.billdowney.util.http.HttpIOUtil;
import com.billdowney.util.return_type.ReturnData;

/**
 * Security自定义处理异常
 * 
 * @author 超级小富翁 - BillDowney
 * @date 2019年2月7日 上午10:11:13
 */
@Component
public class AuthenticationEntryPointServiceImpl implements AuthenticationEntryPoint {

	@Override
	public void commence(HttpServletRequest request, HttpServletResponse response,
			AuthenticationException authException) throws IOException, ServletException {
		HttpIOUtil.outJsonData(response, new ReturnData(authException));
		authException.printStackTrace();
	}

}
